package com.mikao.controller.goods;

import com.mikao.dto.bo.ReqDataTableDto;
import com.mikao.dto.bo.TypeForm;
import com.mikao.dto.vo.RspDataTableDto;
import com.mikao.entity.Type;
import com.mikao.service.TypeService;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author kenny
 */

@RestController
@RequestMapping("/management")
@Scope("prototype")
public class TypeController {

    private TypeService typeService;

    public TypeController(TypeService typeService) {
        this.typeService = typeService;
    }

    @GetMapping("/typeList")
    public RspDataTableDto<Type> typeList(ReqDataTableDto dataTableDTO) {
        return typeService.typeList(dataTableDTO);
    }

    @PostMapping("/addType")
    public void addType(TypeForm typeForm) {
        typeService.addType(typeForm);
    }

    @PostMapping("/deleteType/{id}")
    public void deleteType(@PathVariable Long id) {
        typeService.deleteType(id);
    }

    @GetMapping("/getTypeList")
    public List<Type> getTypeList() {
        return typeService.getTypeList();
    }
}
